<!--$Id: db_deadlock.so,v 10.33 2007/10/26 15:02:55 bostic Exp $-->
<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB: db_deadlock</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<table width="100%"><tr valign=top>
<td>
<b>db_deadlock</b>
</td>
</tr></table>
<hr size=1 noshade>
<tt>
<b><pre>db_deadlock [<b>-Vv</b>]
    [<b>-a e | m | n | o | W | w | y</b>] [<b>-h home</b>] [<b>-L file</b>] [<b>-t sec.usec</b>]</pre></b>
<b>Description</b>
<a name="2"><!--meow--></a>
<p>The db_deadlock utility traverses the database environment lock
region, and aborts a lock request each time it detects a deadlock or a
lock request that has timed out.  By default, in the case of a deadlock,
a random lock request is chosen to be aborted.</p>
<p>This utility should be run as a background daemon, or the underlying
Berkeley DB deadlock detection interfaces should be called in some other way,
whenever there are multiple threads or processes accessing a database
and at least one of them is modifying it.</p>
<p>The options are as follows:</p>
<br>
<b>-a</b><ul compact><li>When a deadlock is detected, abort the locker:
<br>
<b>m</b><ul compact><li>with the most locks</ul>
<b>n</b><ul compact><li>with the fewest locks</ul>
<b>o</b><ul compact><li>with the oldest lock</ul>
<b>W</b><ul compact><li>with the most write locks</ul>
<b>w</b><ul compact><li>with the fewest write locks</ul>
<b>y</b><ul compact><li>with the youngest lock</ul>
<br></ul>
<p>When lock or transaction timeouts have been specified:
<br>
<b>e</b><ul compact><li>abort any lock request that has timed out</ul>
<br></p>
<b>-h</b><ul compact><li>Specify a home directory for the database environment; by
default, the current working directory is used.</ul>
<b>-L</b><ul compact><li>Log the execution of the db_deadlock utility to the specified file in the
following format, where <i>###</i> is the process ID, and the date
is the time the utility was started.
<blockquote><pre>db_deadlock: ### Wed Jun 15 01:23:45 EDT 1995</pre></blockquote>
This file will be removed if the db_deadlock utility exits gracefully.</ul>
<b>-t</b><ul compact><li>Check the database environment every <b>sec</b> seconds plus
<b>usec</b> microseconds to see if a process has been forced to wait
for a lock; if one has, review the database environment lock
structures.</ul>
<b>-V</b><ul compact><li>Write the library version number to the standard output, and exit.</ul>
<b>-v</b><ul compact><li>Run in verbose mode, generating messages each time the detector runs.</ul>
<br>
<p>If the <b>-t</b> option is not specified, db_deadlock will
run once and exit.</p>
<p>The db_deadlock utility uses a Berkeley DB environment (as described for the
<b>-h</b> option, the environment variable <b>DB_HOME</b>, or
because the utility was run in a directory containing a Berkeley DB
environment).  In order to avoid environment corruption when using a
Berkeley DB environment, db_deadlock should always be given the chance to
detach from the environment and exit gracefully.  To cause db_deadlock
to release all environment resources and exit cleanly, send it an
interrupt signal (SIGINT).</p>
<p>The db_deadlock utility does not attempt to create the Berkeley DB
shared memory regions if they do not already exist.  The application
which creates the region should be started first, and then, once the
region is created, the db_deadlock utility should be started.</p>
<p>The <a href="../api_c/lock_detect.html">DB_ENV-&gt;lock_detect</a> method is the underlying method used by the db_deadlock utility.
See the db_deadlock utility source code for an example of using <a href="../api_c/lock_detect.html">DB_ENV-&gt;lock_detect</a>
in a IEEE/ANSI Std 1003.1 (POSIX) environment.</p>
<p>The db_deadlock utility exits 0 on success, and &gt;0 if an error occurs.</p>
<br><b>Environment Variables</b>
<br>
<b>DB_HOME</b><ul compact><li>If the <b>-h</b> option is not specified and the environment variable
DB_HOME is set, it is used as the path of the database home, as described
in <a href="../api_c/env_open.html">DB_ENV-&gt;open</a>.</ul>
<br>
</tt>
<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
</body>
</html>
